# !/usr/bin/env python3
# DolphinDB Inc.
# @Author: DolphinDB
# @Last modification time: 2022.09.01
# @FileName: verifyResult.py

# This script is to compare the WorldQuant 101 alpha results from DolphinDB and Python.
# Remember to get the verify result from DolphinDB and python first.
# Don't forget to change your directory.


import pandas as pd
from pandas.testing import assert_series_equal



def compare_with_origin(file_path):
    compare(file_path, 'result_pandas_origin.csv')

def compare(file1, file2):
    df1 = pd.read_csv(file1)
    df2 = pd.read_csv(file2)
    for i in range(len(df1.columns)):
        try:
            assert_series_equal(df1.iloc[200:, i], df2.iloc[200:, i],check_names=False, check_dtype=False)
            print(f"columns[{i}] passed")
        except AssertionError as e:
            print(f"columns[{i}] failed")
            print(e)

#
# # ddb = pd.read_csv('/YOUR_DIR/ddbVerifyRes.csv')
# # py = pd.read_csv('/YOUR_DIR/pyVerifyRes.csv')
#
# # ddb = pd.read_csv('result_pandas_lite_via_pct_change_rolling_max.csv')
# # ddb = pd.read_csv('result_numpy_origin.csv')
# ddb = pd.read_csv('result_numpy_optimized.csv')
# # ddb = pd.read_csv('result_pandas_lite_via_rolling.csv')
# # ddb = pd.read_csv('result_pandas_lite_via_pct_change.csv')
# py = pd.read_csv('result_pandas_origin.csv')